package
{
	import component.button.MyButton;
	import component.button.MyCheckBox;
	import component.button.MyTimelineButton;
	
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	
	import obecto.core.FLApplication;
	import obecto.event.FLEvent;

	[SWF(backgroundColor="0xCDCDCD")]
	public class ButtonSamples extends FLApplication
	{
		private var myButton : MyButton;
		private var myCheckBox : MyCheckBox;
		private var myTimelineButton : MyTimelineButton;
		
		public function ButtonSamples()
		{
			super();
			
			stage.frameRate = 35;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			myButton = new MyButton();
			myButton.addEventListener(FLEvent.CREATION_COMPLETE, handleButtonCreationComplete);
			
			myCheckBox = new MyCheckBox();
			myCheckBox.addEventListener(FLEvent.CREATION_COMPLETE, handleCheckBoxCreationComplete);
			myCheckBox.addEventListener(MouseEvent.CLICK, handleCheckBoxClick);
			
			myTimelineButton = new MyTimelineButton();
			myTimelineButton.addEventListener(FLEvent.CREATION_COMPLETE, handleTimelineButtonCreationComplete);
		}
		
		private function handleButtonCreationComplete(e : FLEvent) : void 
		{
			myButton.x = 100;
			myButton.y = 60;
			
			myButton.label = "My Button";
			myButton.textField.textColor = myButton.textColor;
			
			addChild(myButton);
		}
		
		private function handleCheckBoxCreationComplete(e : FLEvent) : void 
		{
			myCheckBox.x = 100;
			myCheckBox.y = 130;
			
			myCheckBox.label = "Enabled";
			myCheckBox.textField.textColor = myCheckBox.textColor;
			
			myCheckBox.selected = true;
			
			addChild(myCheckBox);
		}
		
		private function handleTimelineButtonCreationComplete(e : FLEvent) : void 
		{
			myTimelineButton.x = 100;
			myTimelineButton.y = 200;
			
			myTimelineButton.label = "Time-line";
			
			addChild(myTimelineButton);
		}
		
		private function handleCheckBoxClick(e : MouseEvent) : void 
		{
			myButton.enabled = myCheckBox.selected;
			myTimelineButton.enabled = myCheckBox.selected;
		}
		
	}
}